<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>Insert title here</title>
		<link rel="stylesheet" href="./layui/css/layui.css">
		<script type="text/javascript" src="./layui/layui.js"></script>
		<script type="text/javascript" src="js/global.js"></script>
	</head>

	<body>
		<div hidden="hidden" class="layui-form-item" style="margin-top: 20px" onsubmit="false">
			<div class="layui-form-item">
				<label class="layui-form-label">学生ID</label>
				<div class="layui-input-inline">
					<input class="layui-input" name="id" id="id" lay-verify="required" />
				</div>
				<button class="layui-btn" id="serach" data-type="reload" checked>搜索</button>
			</div>
		</div>
		<script type="text/html" id="barDemo">
			<a class="layui-btn layui-btn-xs" lay-event="check">查看</a>
		</script>
		<table id="demo" lay-filter="test"></table>
		<script>
			layui.use(['table'], function() {
				var table = layui.table;
				var $ = layui.jquery; //引入jquery
				//解决跨域
				$.ajaxPrefilter(function(options, originalOptions, jqXHR) {
					options.xhrFields = {
						withCredentials: true
					}
				})

				function getSelectStudentFollow() {
					var id = document.getElementById("id").value;
					//第一个实例
					table.render({
						elem: '#demo',
						toolbar: '#toolbarDemo' //开启头部栏工具
							,
						url: globalData.server + './netFollow/selectStudentFollow?id=' + id //数据接口
							,
						page: true //开启分页
							,
						method: 'POST',
						id: 'testReload',
						cols: [
							[ //表头
								{
									field: 'id',
									title: '学生ID',
									width: 120,
									sort: true,
									fixed: 'left',
									align: 'center'
								}, {
									field: 'stuName',
									title: '学生姓名',
									width: 120,
									align: 'center'
								}, {
									field: 'askerName',
									title: '咨询师姓名',
									width: 150,
									align: 'center'
								}, {
									field: 'isReturnVist',
									title: '是否回访',
									width: 100,
									align: 'center'
								}, {
									field: 'followTime',
									title: '跟踪时间',
									width: 180,
									align: 'center'
								}, {
									field: 'followTRype',
									title: '跟踪类型',
									width: 100,
									align: 'center'
								}, {
									field: 'createTime',
									title: '跟踪创建时间',
									width: 180,
									align: 'center'
								}, {
									field: 'followState',
									title: '跟踪状态',
									width: 100,
									align: 'center'
								}, {
									field: 'age',
									title: '学生年龄',
									width: 120,
									align: 'center'
								}, {
									field: 'sex',
									title: '学生性别',
									width: 120,
									align: 'center'
								}, {
									field: 'phone',
									title: '联系电话',
									width: 120,
									align: 'center'
								}, {
									field: 'msgSource',
									title: '学生来源',
									width: 120,
									align: 'center'
								}, {
									field: 'sourceUrl',
									title: '来源地址',
									width: 120,
									align: 'center'
								}, {
									field: 'qq',
									title: 'QQ',
									width: 120,
									align: 'center'
								}, {
									field: 'weiXin',
									title: '微信',
									width: 120,
									align: 'center'
								}, {
									field: 'right',
									title: '操作',
									toolbar: '#barDemo',
									align: 'center',
									width: 150
								}
							]
						]
					});
					//监听工具条
					table.on('tool(test)', function(obj) { //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
						var data = obj.data; //获得当前行数据
						if(obj.event === 'check') { //查看详情
							layer.open({ //打开一个页面
								type: 2, //在当前页面之上以弹框的形式，展示编辑页面
								area: ['450px', '500px'], //页面宽高
								content: 'netfollows-check.html', //页面所在位置
								title: '您正在查看追踪信息编号为' + obj.data.id + '的信息',
								success: function(layero, index) {
									var body = layer.getChildFrame('body', index);
									body.contents().find("#stuName").val(obj.data.stuName);
									body.contents().find("#followTime").val(obj.data.followTime);
									body.contents().find("#nextFollowTime").val(obj.data.nextFollowTime);
									body.contents().find("#followTRype").val(obj.data.followTRype);
									body.contents().find("#followState").val(obj.data.followState);
									body.contents().find("#content").val(obj.data.content);
									body.contents().find("#createTime").val(obj.data.createTime);
									body.contents().find("#askerName").val(obj.data.askerName);
									body.contents().find("#age").val(obj.data.age);
									body.contents().find("#sex").val(obj.data.sex);
									body.contents().find("#phone").val(obj.data.phone);
									body.contents().find("#msgSource").val(obj.data.msgSource);
									body.contents().find("#sourceUrl").val(obj.data.sourceUrl);
									body.contents().find("#qq").val(obj.data.qq);
									body.contents().find("#weiXin").val(obj.data.weiXin);
								},
								end: function() {
									window.location.reload(); //当窗口关闭后刷新页面
								}
							});
						}
					});
				}
				setTimeout(function() {
					getSelectStudentFollow();
				}, 100);
			});
		</script>
	</body>

</html>